
package com.probiz.estore.customer.service.dwr;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.probiz.estore.common.model.customer.ReviewEligibility;
import com.probiz.estore.common.model.system.AppUser;
import com.probiz.estore.customer.service.ReviewEligibilityManager;
import com.probiz.estore.webapp.util.RequestContext;

public class ReviewEligibilityDwrImpl {
	protected final transient Log log= LogFactory.getLog(getClass());
	private ReviewEligibilityManager reviewEligibilityManager;
	
	public void setReviewEligibilityManager(
			ReviewEligibilityManager reviewEligibilityManager) {
		this.reviewEligibilityManager = reviewEligibilityManager;
	}


	/**
	 * 获得客户对商品评论的资质标识
	 * @param customerId
	 * @param productId
	 * @return  ReviewEligibility.RESULT_UNAVAILABLE,RESULT_AVAILABLE,RESULT_OVERCOUNT,RESULT_OVERTIME
	 */
	public Short getEligibility(HttpServletRequest request,HttpServletResponse response, Integer productId){
		if (RequestContext.isAnonymousUser()) {
			return ReviewEligibility.RESULT_NOLOG;
		}
		AppUser customer = (AppUser) RequestContext.getCurrentUser();
		return reviewEligibilityManager.getEligibility(customer.getAppuserId(), productId);
	}

	
}
